package dev.ece.suit.loader.models.dae;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang3.StringUtils;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="library_images")
public class DAEImages {
	
	@XmlElement(name="image")
	private DAEImage[] image;

	public Map<String, String> createImageMap() {
		Map<String, String> map = new ConcurrentHashMap<String, String>();
		if(this.image != null) {
			for(DAEImage image: this.image) {
				map.put(StringUtils.join("#", image.getId()), image.getInit_from());
			}
		}
		return map;
	}
	
	public DAEImage[] getImage() {
		return image;
	}

	public void setImage(DAEImage[] image) {
		this.image = image;
	}
	
	@XmlAccessorType(XmlAccessType.FIELD)
	@XmlRootElement(name="image")
	public static class DAEImage {

		@XmlAttribute(name="id")
		private String id;
		
		@XmlAttribute(name="name")
		private String name;
		
		@XmlElement(name="init_from")
		private String init_from;

		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getInit_from() {
			return init_from;
		}

		public void setInit_from(String init_from) {
			this.init_from = init_from;
		}
		
	}
	
}
